$package("boc.html");
$import("boc.html.FormELUtil");
boc.html.TextInput=function(){
	boc.html.FormELUtil.call(this);
	this.create=t._create;
	//this.onEnterKey=new Function();
	//this.onLeftKey=new Function();
	//this.onRightKey=new Function();
	//this.onUpKey=new Function();
	//this.onDownKey=new Function();
}

var t=boc.html.TextInput;
window.TextInput=t;

boc.html.TextInput.prototype.create=function(){
	var input=document.createElement("input");
	input.type="text";
	t.applyTo(input);
	return input;
};
boc.html.TextInput.prototype.applyTo=function(el){
	t.call(el);
	el.addEvent("keyup",this._keyEvt);
}
boc.html.TextInput.prototype._keyEvt=function(evt){
	evt=evt||window.event;
	var o=evt.srcElement||evt.target;
	var notify=function(s){
		if(eval("o."+s)!=null && typeof(eval("o."+s))=="function" )
			eval("o."+s)(evt);
		else if(o.getAttribute(s))
		{
			function t(event){	eval(o.getAttribute(s))};
			t.call(o,evt);
		}
	}
	switch(evt.keyCode)
	{
	  case 13:
		notify("onEnterKey");
		break;
	  case 37://left
		notify("onLeftKey");
		break;
	  case 38://up
		notify("onUpKey");
		break;
	  case 39://right
		notify("onRightKey");
		break;
	  case 40://down
		notify("onDownKey");
		break;
	  case 9://TAB
		notify("onTabKey");
		break;
	  case 27://ESC
		notify("onESCKey");
		break;
	}
}

boc.html.TextInput.prototype.applyAll=function(){
	var input=document.body.getElementsByTagName("input");
	for(var i=input.length-1;i>=0;i--)
	{
		var t=input[i].type.toLowerCase();
		if(t=="" || t=="text" || t=="password")
		{
			this.applyTo(input[i]);
		}
	}
}

